package com.rpp.service.impl;

import com.rpp.bean.Person;
import com.rpp.repository.PersonRepository;
import com.rpp.service.INeo4jPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author peng
 * @Date 2020/10/13 2:25 下午
 */
@Service("personService")
public class Neo4jPersonService implements INeo4jPersonService {

    @Autowired
    private PersonRepository personRepository;

    @Override
    public List<Person> getAll() {
        List<Person> datas = new ArrayList<>();
        personRepository.findAll().forEach(person -> datas.add(person));
        return datas;
    }

    @Override
    public Person save(Person person) {
        return personRepository.save(person);
    }

    @Override
    public List<Person> personList(double money) {
        return personRepository.personList(money);
    }

    @Override
    public List<Person> shortestPath(String startName, String endName) {
        return personRepository.shortestPath(startName, endName);
    }

    @Override
    public List<Person> personListDept(String name) {
        return personRepository.personListDept(name);
    }

    @Override
    public List<Person> findAllPath(String startName, String endName) {
        return personRepository.findAllPath(startName, endName);
    }
}
